<?php
	$relations = $model->getMetadata()->relations;
	if(!$this->useGroup) $this->fields = array('baseInfo'=>$this->fields);
	foreach(array_keys($this->fields) as $one) {
		$title[$one] = $form->labelEx($model, $one);
	}
	$this->beginWidget('Block', array('title' => $title));
	
	$relations = $model->getMetadata()->relations;
	foreach($this->fields as $gName=>$gFields) {
		echo "<div class='tab' id='{$gName}'>";
		if(is_string($gFields)) {
			include Yii::getPathOfAlias($gFields).'.php';
		} else {
			if(isset($relations[$gName]) && $relations[$gName] instanceof CHasManyRelation) {
				
				Yii::createComponent(array(
					'class' => 'HasManyForm',
					'model' => $model,
					'activeForm' => $form,
					'fields' => $gFields,
					'relationName' => $gName,
				))->render();
			
			
			} else {
				echo "<table class='detail mgb10'>";
				foreach($gFields as $name=>$field) {
					if(!$field->getIsVisible()) continue;
					$label = $model->getAttributeLabel($name);
					$width = strlen($label) * 11;
					$style = $field instanceof ActiveFormField && isset($field->params[0]) && $field->params[0] == 'hiddenField' ? 'style="display:none"' : ''; 
					if(($hint = $model->getAttributeHint($name))!==null) {
						$htmlOptions = array(
							'class' => 'label-question',	
							'title' => $hint,
						);
					} else {
						$htmlOptions = array();
					}
					echo 
					'<tr '.$style.'>'.
						'<th class="vtop" width="'.$width.'px">'.$form->labelEx($model, $name, $htmlOptions).'：</th>'.
						'<td>'.$field->render().
						$form->error($model, $name).'</td>'.
					'</tr>';
				}
				echo '</table>';
			}
		}
		echo '</div>';
		
	}
	
	$this->endWidget();
?>
<script>
$('.label-question').poshytip({
	className: 'tip-yellow',
	alignTo: 'target',
	alignX: 'right',
	alignY: 'center',
	offsetX: 15,
	offsetY: 5,
	showTimeout: 1,
	hideAniDuration: false,
	showAniDuration: false
});
</script>
